package com.ruoyi.web.wx.controller;


import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.CustomException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.system.service.ISysUserService;
import com.ruoyi.wx.service.IPtExpVideoService;
import com.ruoyi.wx.service.IPtQuestionService;
import com.ruoyi.wx.service.IPtScoreService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author moxiu
 * @since 2021-11-13
 */
@RestController
@RequestMapping("/wx/ptQuestion")
public class PtQuestionController {

	@Autowired
	private IPtQuestionService ptQuestionService;

	@Autowired
	private IPtScoreService iPtScoreService;

	@Autowired
	private ISysUserService iSysUserService;

	@GetMapping("/getQuestion")
	@ApiOperation("获取该实验下面的题目")
	public AjaxResult getQuestion(Long expId) {

		return AjaxResult.success(ptQuestionService.getQuestionByExpId(expId));
	}

	@GetMapping("/score")
	@ApiOperation("给预习分")
	public AjaxResult score(Long expId,Double score) {
		if (score > Constants.SY_PREVIEW || score < Constants.MIN) {
			throw new CustomException("打分不在正常范围内");
		}
		iPtScoreService.createScore(expId,score);
		return AjaxResult.success("预习成功");
	}

}
